package com.platform;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * Description: 后台管理
 *
 * @author YangLong [410357434@163.com]
 * @version V1.0
 * @date 2020/8/24
 */
@Slf4j
@EnableAsync
@EnableCaching
@EnableTransactionManagement
@SpringBootApplication(scanBasePackages = {"com.platform.*"})
public class ShopAdminApplication {

    public static void main(String[] args) {
        try {
            SpringApplication.run(ShopAdminApplication.class, args);
        } catch (Exception e) {
            log.error("can't run shop admin application!", e);
        }
    }

    @Bean
    @Qualifier
    public TaskExecutor taskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(2);
        executor.setMaxPoolSize(8);
        executor.setThreadNamePrefix("async_");
        return executor;
    }
}
